package com.load.factories;

import static com.load.utils.FileUtil.*;

import org.tmatesoft.svn.core.*;
import org.tmatesoft.svn.core.io.SVNRepository;

import com.database.objects.*;
import com.load.objects.MySVNDirEntry;

public class FileFactory {

	public static File createFile(Commit commit, SVNLogEntryPath entryPath) {
		String path = entryPath.getPath();
		Status status = Status.createStatus("" + entryPath.getType());

		if (pathIsFileOO(path)) {
			return new FileOO(path, false, status, commit);
		} else {
			return new FileNoOO(path, false, status, commit);
		}
	}

	public static File createFile(SVNRepository repository, MySVNDirEntry entry) {
		Commit commit = CommitFactory.createCommit(entry);
		File file = null;
		if (pathIsFileOO(entry.getPath())) {
			file = new FileOO(entry.getPath(), false, Status.UNKNOWN, commit);
		} else {
			file = new FileNoOO(entry.getPath(), false, Status.UNKNOWN, commit);
		}
		file.setBaos(repository);
		return file;
	}

}